package com.aliware.tianchi;

import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.atomic.AtomicLong;
import java.util.concurrent.atomic.AtomicLongArray;

public class ProviderInfo {

    private volatile int serverWeight = 15;

    private volatile int avgSpendTime;

    private volatile String env = "large";

    public int getLen() {
        return len;
    }

    public void setLen(int len) {
        this.len = len;
    }

    private volatile int len = 1;

    public long getAvgSpendDuringSecond() {
        return avgSpendDuringSecond;
    }

    public void setAvgSpendDuringSecond(long avgSpendDuringSecond) {
        this.avgSpendDuringSecond = avgSpendDuringSecond;
    }

    private volatile long avgSpendDuringSecond = 50;

    //这里的max并不进行限流，只用在负载均衡算法中来判断是否快达到最大线程数，动态更新
    private AtomicInteger max = new AtomicInteger(190);

    public AtomicInteger getMax() {
        return max;
    }

    public void setMax(AtomicInteger max) {
        this.max = max;
    }

    /*    public int getIndex() {
        return index;
    }

    public void setIndex(int index) {
        this.index = index;
    }

    private int index;*/

    public AtomicLong getLastActiveTime() {
        return LastActiveTime;
    }

    public void setLastActiveTime(AtomicLong lastActiveTime) {
        LastActiveTime = lastActiveTime;
    }

    private AtomicLong LastActiveTime;

    private AtomicLong allReqCount = new AtomicLong(0);
    private AtomicLong allSpendTimeTotal = new AtomicLong(0);

    public AtomicLongArray getCount() {
        return count;
    }

    private AtomicLongArray count = new AtomicLongArray(7);
    //活跃连接数
    private AtomicLong allActiveCount = new AtomicLong(0);

    public ProviderInfo() {}


    public int getServerWeight() {
        return serverWeight;
    }

    public int getAvgSpendTime() {
        return avgSpendTime;
    }


    public AtomicLong getAllReqCount() {
        return allReqCount;
    }

    public AtomicLong getAllSpendTimeTotal() {
        return allSpendTimeTotal;
    }

    public AtomicLong getAllActiveCount() {
        return allActiveCount;
    }

    public void setServerWeight(int serverWeight) {
        this.serverWeight = serverWeight;
    }

    public void setAvgSpendTime(int avgSpendTime) {
        this.avgSpendTime = avgSpendTime;
    }



}
